import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';

export const Layout = () => import('@/layout/index.vue');

// 静态路由
export const constantRoutes: RouteRecordRaw[] = [
  {
    path: '/redirect',
    component: Layout,
    meta: { hidden: true },
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index.vue')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    meta: { hidden: true }
  },
  {
    path: '/dataStatistics',
    component: Layout,
    meta: {title:'系统管理',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {
        path:"dataDoc",
        name:"dataDoc",
        component: () => import('@/views/dataStatistics/index.vue'),
        meta:{title: '数据统计', icon: 'money', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/setword',
    component: Layout,
    meta: {title:'集字',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {
        path:"blessing",
        name:"blessing",
        component: () => import('@/views/setword/blessing/index.vue'),
        meta:{title: '副式', icon: 'advert', hidden: false, roles: ['admin'], keepAlive: true}
      },
      {
        path:"broduction",
        name:"broduction",
        component: () => import('@/views/setword/broduction/index.vue'),
        meta:{title: '作品', icon: 'advert', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/stoneInscription',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {
        path:"inscription",
        name:"inscription",
        component: () => import('@/views/stoneInscription/index.vue'),
        meta:{title: '碑帖', icon: 'brand', hidden: false, roles: ['admin'], keepAlive: true},
      },
      {
        path:"versions",
        name:"versions",
        component:()=>import('@/views/stoneInscription/versions.vue'),
        meta:{title: '碑帖版本', hidden: true, roles: ['admin'], keepAlive: true},
      },
      {
        path:"versionDetail",
        name:"versionDetail",
        component:()=>import('@/views/stoneInscription/versionDetail.vue'),
        meta:{title: '碑帖版本', hidden: true, roles: ['admin'], keepAlive: true},
      },
      
      
    ]
  },
  {
    path: '/spreadSheet',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"Sheet",
        name:"Sheet",
        component: () => import('@/views/spreadSheet/index.vue'),
        meta:{title: '展讯', icon: 'cascader', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/sealCutting',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"Cutting",
        name:"Cutting",
        component: () => import('@/views/sealCutting/index.vue'),
        meta:{title: '篆刻', icon: 'chart', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/calligraphyPainting',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"Painting",
        name:"Painting",
        component: () => import('@/views/calligraphyPainting/index.vue'),
        meta:{title: '书画论', icon: 'client', hidden: false, roles: ['admin'], keepAlive: true}
      },
      {

        path:"Paintingzj",
        name:"Paintingzj",
        component: () => import('@/views/calligraphyPainting/zj.vue'),
        meta:{title: '章节目录', icon: '', hidden: true, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/draw',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {
        path:"draw",
        name:"draw",
        component: () => import('@/views/draw/index.vue'),
        meta:{title: '绘画', icon: 'coupon', hidden: false, roles: ['admin'], keepAlive: true}
      },
      {
        path:"checkdetail",
        name:"checkdetail",
        component: () => import('@/views/draw/checkversion.vue'),
        meta:{title: '查看', icon: 'coupon', hidden: true, roles: ['admin'], keepAlive: true}
      },
      {
        path:"drawdetails",
        name:"drawdetails",
        component: () => import('@/views/draw/drawdetails.vue'),
        meta:{title: '详情', icon: 'coupon', hidden: true, roles: ['admin'], keepAlive: true}
      },
    ]
  },
  {
    path: '/putDisplay',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"Display",
        name:"Display",
        component: () => import('@/views/putDisplay/index.vue'),
        meta:{title: '展览', icon: 'dashboard', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/solicitContributions',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"Contributions",
        name:"Contributions",
        component: () => import('@/views/solicitContributions/index.vue'),
        meta:{title: '征稿', icon: 'dict_item', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/userManagement',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"urManagement",
        name:"urManagement",
        component: () => import('@/views/userManagement/index.vue'),
        meta:{title: '用户管理', icon: 'dict', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/opinionFeedback',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"Feedback",
        name:"Feedback",
        component: () => import('@/views/opinionFeedback/index.vue'),
        meta:{title: '意见反馈', icon: 'document', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/privacyPolicy',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"Policy",
        name:"Policy",
        component: () => import('@/views/privacyPolicy/index.vue'),
        meta:{title: '隐私政策', icon: 'download', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/recurrentManagement',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"Management",
        name:"Management",
        component: () => import('@/views/recurrentManagement/index.vue'),
        meta:{title: '轮播管理', icon: 'drag', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/triageManagement',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"trManagement",
        name:"trManagement",
        component: () => import('@/views/triageManagement/index.vue'),
        meta:{title: '分类管理', icon: 'edit', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/systemManagement',
    component: Layout,
    meta: {title:'',icon:'system',hidden:false,roles:['admin'],keepAlive:true},
    children:[
      {

        path:"syManagement",
        name:"syManagement",
        component: () => import('@/views/systemManagement/index.vue'),
        meta:{title: '系统管理', icon: 'eye', hidden: false, roles: ['admin'], keepAlive: true}
      }
    ]
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        name: 'Dashboard',
        meta: { title: 'dashboard', icon: 'homepage', affix: true }
      },
      {
        path: '401',
        component: () => import('@/views/error-page/401.vue'),
        meta: { hidden: true }
      },
      {
        path: '/404',
        component: () => import('@/views/error-page/404.vue'),
        meta: { hidden: true }
      }
    ]
  }

  // 外部链接
  /*{
        path: '/external-link',
        component: Layout,
        children: [
            {
                path: 'https://www.cnblogs.com/haoxianrui/',
                meta: { title: '外部链接', icon: 'link' }
            }
        ]
    }*/
  // 多级嵌套路由
  /* {
         path: '/nested',
         component: Layout,
         redirect: '/nested/level1/level2',
         name: 'Nested',
         meta: {title: '多级菜单', icon: 'nested'},
         children: [
             {
                 path: 'level1',
                 component: () => import('@/views/nested/level1/index.vue'),
                 name: 'Level1',
                 meta: {title: '菜单一级'},
                 redirect: '/nested/level1/level2',
                 children: [
                     {
                         path: 'level2',
                         component: () => import('@/views/nested/level1/level2/index.vue'),
                         name: 'Level2',
                         meta: {title: '菜单二级'},
                         redirect: '/nested/level1/level2/level3',
                         children: [
                             {
                                 path: 'level3-1',
                                 component: () => import('@/views/nested/level1/level2/level3/index1.vue'),
                                 name: 'Level3-1',
                                 meta: {title: '菜单三级-1'}
                             },
                             {
                                 path: 'level3-2',
                                 component: () => import('@/views/nested/level1/level2/level3/index2.vue'),
                                 name: 'Level3-2',
                                 meta: {title: '菜单三级-2'}
                             }
                         ]
                     }
                 ]
             },
         ]
     }*/
];

/**
 * 创建路由
 */
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes as RouteRecordRaw[],
  // 刷新时，滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 })
});

/**
 * 重置路由
 */
export function resetRouter() {
  router.replace({ path: '/login' });
  location.reload();
}

export default router;
